package com.cgbl.cg.ui.mine

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.cgbl.cg.BR
import com.cgbl.cg.R
import com.cgbl.cg.adapter.CityAdapter
import com.cgbl.cg.adapter.CourseAdvertAdapter
import com.cgbl.cg.databinding.AppFragmentCourseProfileBinding
import com.cgbl.cg.vm.course.CourseInfoViewModel
import com.cgbl.cg.vm.mine.CourseProfileViewModel
import com.lxj.xpopup.XPopup
import com.robot.base.base.activity.GLBaseFragment
import com.robot.base.model.CourseInfoBean
import com.robot.base.model.CourseInfoFileBean
import com.robot.base.util.WebViewUtil

class CourseProfileFragment :
    GLBaseFragment<AppFragmentCourseProfileBinding, CourseInfoViewModel>() {

    lateinit var mAdapter: CourseAdvertAdapter
    override fun initContentView(

        inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?
    ): Int = R.layout.app_fragment_course_profile

    override fun initVariableId(): Int = BR.viewModel

    override fun initComponents() {
        mAdapter = CourseAdvertAdapter()
        binding.courseAdvert.apply {
            layoutManager = LinearLayoutManager(context)
            adapter = mAdapter
        }
    }

    fun setCourseProfileData(data: CourseInfoBean) {
        viewModel.setData(data)
        WebViewUtil.loadData(binding.dkWebView, data.introduce)
        mAdapter.setNewInstance(data.infoFileRespVOS as MutableList<CourseInfoFileBean>?)
    }
}